//
//  PersonVC.m
//  Book
//
//  Created by 123 on 16-3-31.
//  Copyright (c) 2016年 陈凯. All rights reserved.
//

#import "PersonVC.h"
#import "Masonry.h"
#import "UPdateVC.h"
#import "MyBookVC.h"
@interface PersonVC ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation PersonVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title=@"个人信息";
    _dataArray=[[NSMutableArray alloc]initWithObjects:@"头像",@"用户名", @"邮箱",@"昵称",@"我的书架",@"账号",nil];
    _ResultArray=[[NSMutableArray alloc]initWithObjects:@"head",@"chenkai", @"男",@"ck",@" ",@"1243435654",nil];

    _tableview.delegate=self;
    _tableview.dataSource=self;
         }
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(section==0){
    return 6;
    }else{
        return 1;
    }
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
    if(!cell){
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        UILabel*label=[[UILabel alloc]init];
        label.frame=CGRectMake(240, 0, 80, 44);
        label.tag=10;
        [cell.contentView addSubview:label];
    }
    if(indexPath.section==0){
        if(indexPath.row==0){
    //UIImageView*imgV=[[UIImageView alloc]init];
        }
        cell.textLabel.text=_dataArray[indexPath.row];
        UILabel*label=(UILabel*)[cell viewWithTag:10];
        label.text=_ResultArray[indexPath.row];
    }
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.section==0){
        if(indexPath.row==3){
            UPdateVC*vc=[[UPdateVC alloc]init];
            vc.delegate=self;
            [self.navigationController pushViewController:vc animated:YES];
        }
        if(indexPath.row==4){
            MyBookVC*vc=[[MyBookVC alloc]init];
                      [self.navigationController pushViewController:vc animated:YES];
        }

    }
}
-(void)viewWillAppear:(BOOL)animated{
    if(self.m.length!=0){
        NSString* str= [NSString stringWithFormat:@"%d岁",2016-[self.m intValue]];
        [_ResultArray replaceObjectAtIndex:3 withObject:str];
        NSLog(@"%@",self.m);
    [_tableview reloadData];
}
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
